home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Language/OS - Multiplatform Resource Library
/
LANGUAGE OS.iso
/
cpp_libs
/
awe2-0_1.lha
/
awe2-0.1
/
Src
/
RCS
/
SpinLock.h,v
< prev
next >
Wrap
Text File
|
1989-02-23
|
3KB
|
207 lines
head 3.2;
branch ;
access ;
symbols ;
locks grunwald:3.2; strict;
comment @ * @;
3.2
date 89.02.20.15.37.43; author grunwald; state Exp;
branches ;
next 3.1;
3.1
date 88.12.20.13.50.21; author grunwald; state Exp;
branches ;
next 1.4;
1.4
date 88.10.30.13.06.11; author grunwald; state Exp;
branches ;
next 1.3;
1.3
date 88.09.28.22.13.46; author grunwald; state Exp;
branches ;
next 1.2;
1.2
date 88.09.21.20.51.47; author grunwald; state Exp;
branches ;
next 1.1;
1.1
date 88.09.18.16.42.08; author grunwald; state Exp;
branches ;
next ;
desc
@@
3.2
log
@Start using Gnu library heaps for schedulers
@
text
@// This may look like C code, but it is really -*- C++ -*-
//
// Copyright (C) 1988 University of Illinois, Urbana, Illinois
//
// written by Dirk Grunwald (grunwald@@cs.uiuc.edu)
//
#ifndef SpinLock_h
#define SpinLock_h
//
// Implement a UNIX process spin-lock. While suitable for Threads,
// it's not clear it makes sense. Better to schedule another
// thread, typically.
//
#include "assert.h"
#include "Config.h"
static const char SpinLockFree = '\x00';
static const char SpinLockHeld = '\xff';
class SpinLock {
int state; // only a byte is used -- make alignment explicit
int pCount;
public:
inline SpinLock();
inline ~SpinLock();
void reserve();
void release();
int count();
};
inline
SpinLock::SpinLock()
{
state = SpinLockFree;
pCount = 0;
}
inline
SpinLock::~SpinLock()
{
assert(state == SpinLockFree);
}
#ifndef USE_SHARED_MEMORY
inline void
SpinLock::reserve()
{
assert(state == SpinLockFree);
state = ~SpinLockFree;
}
#endif
inline void
SpinLock::release()
{
assert(state != SpinLockFree);
state = SpinLockFree;
}
inline int
SpinLock::count()
{
return pCount;
}
#endif
@
3.1
log
@Steay version
@
text
@@
1.4
log
@*** empty log message ***
@
text
@@
1.3
log
@*** empty log message ***
@
text
@d1 8
a8 2
#ifndef HardSpinLock_h
#define HardSpinLock_h
d17 1
d19 2
a20 2
static const char HardSpinLockFree = '\x00';
static const char HardSpinLockHeld = '\xff';
d22 1
a22 1
class HardSpinLock {
d26 2
a27 2
inline HardSpinLock();
inline ~HardSpinLock();
d34 1
a34 1
HardSpinLock::HardSpinLock()
d36 1
a36 1
state = HardSpinLockFree;
d41 1
a41 1
HardSpinLock::~HardSpinLock()
d43 1
a43 1
assert(state == HardSpinLockFree);
d46 9
d56 1
a56 1
HardSpinLock::release()
d58 2
a59 2
assert(state != HardSpinLockFree);
state = HardSpinLockFree;
d63 1
a63 1
HardSpinLock::count()
@
1.2
log
@*** empty log message ***
@
text
@d19 2
a20 2
HardSpinLock();
~HardSpinLock();
@
1.1
log
@Initial revision
@
text
@d16 1
a16 1
char state;
d42 1
a42 1
assert(state == HardSpinLockHeld);
@